home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / AmigaE / Src / OOmodules / library / device / printer.e < prev    next >
Encoding:
Text File  |  1996-02-18  |  5.5 KB  |  239 lines

  1. OPT MODULE
  2. OPT OSVERSION=37
  3. OPT EXPORT
  4.  
  5. -> NOTE: some modifications to this by JEVR3
  6. -> All 'self.open()' statements changed to reflect use of 'new()'
  7.  
  8. MODULE  'devices/printer', 'exec/devices', 'exec/io', 'exec/nodes',
  9.         'exec/ports','exec/devices',
  10.         'oomodules/library/device'
  11.  
  12. OBJECT printer OF device
  13. /****** printer/--printer-- ******************************************
  14.  
  15.     NAME 
  16.         printer of device
  17.  
  18.     PURPOSE
  19.         To provide basic means to control every printer.
  20.  
  21.     CREATION
  22.         Back in February of 1995  by Gregor Goldbach
  23.  
  24.     HISTORY
  25.         some minor modifications by Trey
  26. ******************************************************************************
  27.  
  28. History
  29.  
  30.  
  31. */
  32. ENDOBJECT
  33.  
  34. -> JEVR3 addition: init() sets default name and unit for printer.device.
  35.  
  36. PROC init() OF printer
  37. /****** printer/init ******************************************
  38.  
  39.     NAME 
  40.         init() -- Initialization of the object.
  41.  
  42.     SYNOPSIS
  43.         printer.init()
  44.  
  45.     FUNCTION
  46.         Set default name and unit.
  47. ******************************************************************************
  48.  
  49. History
  50.  
  51.  
  52. */
  53.  self.identifier:={defaultPrinter}
  54.  self.unit:=0
  55. ENDPROC
  56.  
  57. PROC rawwrite(zkette,laenge) OF printer
  58. /****** printer/rawwrite ******************************************
  59.  
  60.     NAME 
  61.         rawwrite() -- Printing chars without esc substitution.
  62.     SYNOPSIS
  63.         printer.rawwrite(PTR TO CHAR, LONG)
  64.  
  65.     FUNCTION
  66.         Sends the characters to the printer. Esc-sequences will not be
  67.         substituted. Opens the printer.device if necessary.
  68.  
  69.     INPUTS
  70.         PTR TO CHAR -- The characters to print
  71.  
  72.         LONG -- The number of characters to print
  73.  
  74. ******************************************************************************
  75.  
  76. History
  77.  
  78.  
  79. */
  80.  
  81. -> JEVR3 modification; removed surrounding IF/ENDIF; now in open() itself
  82. -> Also tests to insure device opened.
  83.  
  84.   IF self.open()
  85.  
  86.     self.io::iostd.data := zkette
  87.     self.io::iostd.length := laenge
  88.     self.io::iostd.command := PRD_RAWWRITE
  89.  
  90.     self.doio()
  91.  
  92.     self.lasterror := self.io.error
  93.   ENDIF
  94. ENDPROC
  95.  
  96. PROC write(zkette,laenge) OF printer
  97. /****** printer/write ******************************************
  98.  
  99.     NAME 
  100.         write() -- Printing chars with esc substitution.
  101.     SYNOPSIS
  102.         printer.write(PTR TO CHAR, LONG)
  103.  
  104.     FUNCTION
  105.         Sends the characters to the printer. Esc-sequences will be
  106.         substituted. Opens the printer.device if necessary.
  107.  
  108.     INPUTS
  109.         PTR TO CHAR -- The characters to print
  110.  
  111.         LONG -- The number of characters to print
  112.  
  113. ******************************************************************************
  114.  
  115. History
  116.  
  117.  
  118. */
  119. -> JEVR3 modification; removed surrounding IF/ENDIF; now in open() itself
  120. -> Added test to see if it actually opened.
  121.  
  122.   IF self.open()
  123.  
  124.  
  125.     self.io::iostd.data := zkette
  126.     self.io::iostd.length := laenge
  127.  
  128.     self.io::iostd.command := CMD_WRITE
  129.  
  130.     self.doio()
  131.  
  132.     self.lasterror := self.io.error
  133.   ENDIF
  134. ENDPROC
  135.  
  136. PROC xcommand(kommando,p0=NIL,p1=NIL,p2=NIL,p3=NIL) OF printer
  137. /****** printer/xcommand ******************************************
  138.  
  139.     NAME 
  140.         xcommand() -- execute printer command.
  141.  
  142.     SYNOPSIS
  143.         printer.xcommand(LONG, LONG=NIL, LONG=NIL, LONG=NIL, LONG=NIL)
  144.  
  145.     FUNCTION
  146.         Executes a printer command with the given parameters such as setting
  147.         left and right border, justification etc.
  148.         Opens the printer.device if necessary.
  149.  
  150.     INPUTS
  151.         command:LONG -- the printer command to be executed
  152.         param0-3:LONG -- command parameters
  153.  
  154. ******************************************************************************
  155.  
  156. History
  157.  
  158. DESCRIPTION
  159.  
  160.  
  161. */
  162.  
  163. -> JEVR3 modification; removed surrounding IF/ENDIF; now in open() itself
  164. -> Added test to see if it actually opened.
  165.  
  166.   IF self.open()
  167.  
  168.   self.io::ioprtcmdreq.prtcommand := kommando
  169.   self.io::ioprtcmdreq.parm0 := p0
  170.   self.io::ioprtcmdreq.parm1 := p1
  171.   self.io::ioprtcmdreq.parm2 := p2
  172.   self.io::ioprtcmdreq.parm3 := p3
  173.   self.io.command := PRD_PRTCOMMAND
  174.   self.doio()
  175.  
  176.   ENDIF
  177.  
  178. ENDPROC
  179.  
  180. PROC graphicdump(rport,cmap,vmodes,srcx,srcy,srcwidth,srcheight,destcols,destrows,special) OF printer
  181. /****** printer/graphicdump ******************************************
  182.  
  183.     NAME 
  184.         graphicdump() -- Print a part of a rastport.
  185.  
  186.     SYNOPSIS
  187.         printer.graphicdump(10 LONGs)
  188.  
  189.     FUNCTION
  190.         It prints a part of a rastport.
  191.  
  192.     INPUTS
  193.         rport -- the RastPort containing the image to print
  194.         cmap -- screen's ColorMap
  195.         vmodes -- ViewModes of the screen
  196.         srcx,srcy,
  197.         srcwidth,
  198.         srcheight -- source dimensions: start point & width & height
  199.         destcols,
  200.         destrows    - dimensions on the printer in points
  201.         Special     - special flags
  202.  
  203. ******************************************************************************
  204.  
  205. History
  206.  
  207.  
  208. */
  209.  
  210. -> JEVR3 modification; removed surrounding IF/ENDIF; now in open() itself
  211. -> Added test to make sure device was opened.
  212.  
  213.  IF self.open()
  214.   self.io::iodrpreq.rastport    := rport
  215.   self.io::iodrpreq.colormap    := cmap
  216.   self.io::iodrpreq.modes   := vmodes
  217.   self.io::iodrpreq.srcx        := srcx
  218.   self.io::iodrpreq.srcy        := srcy
  219.   self.io::iodrpreq.srcwidth    := srcwidth
  220.   self.io::iodrpreq.srcheight   := srcheight
  221.   self.io::iodrpreq.destcols    := destcols
  222.   self.io::iodrpreq.destrows    := destrows
  223.   self.io::iodrpreq.special := special
  224.  
  225.   self.io.command := PRD_DUMPRPORT
  226.   self.doio()
  227.  ENDIF
  228.  
  229. ENDPROC
  230.  
  231. -> JEVR3 addition: strings for the default printer.
  232.  
  233. defaultPrinter:
  234.  CHAR 'printer.device',0
  235. /*EE folds
  236. -1
  237. 12 20 16 18 19 36 22 37 25 41 28 48 
  238. EE folds*/
  239.